//
//  CommemtView.m
//  HubeiHotel
//
//  Created by LiBenCan on 17/11/15.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "CommemtView.h"
@interface CommemtView()
@end
@implementation CommemtView

-(void)CommetNumber:(NSString *)commentNumber CollectNumber:(NSString *)collectNumber IsComment:(BOOL)isComment IsCollect:(BOOL)isCollect{
    
    self.backgroundColor = [UIColor whiteColor];
    
    if (!_commentImageV) {
        
        //收藏数量
        _collectNumberLab = [UILabel new];
        _collectNumberLab.textColor = TextBlackGray;
        _collectNumberLab.font = [UIFont systemFontOfSize:15*screenW_6];
        _collectNumberLab.textAlignment = NSTextAlignmentLeft;
        _collectNumberLab.text = collectNumber;
        [_collectNumberLab sizeToFit];
         _collectNumberLab.userInteractionEnabled = YES;
        [self  addSubview:_collectNumberLab];
        _collectNumberLab.tag = 1;
        [_collectNumberLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(0);
            make.height.equalTo(@(40*screenW_6));
            make.right.equalTo(self).offset(-12*screenW_6);
            make.width.equalTo(@(_collectNumberLab.frame.size.width+5*screenW_6));
        }];
        
        //收藏图片
        _collectImageV = [[UIImageView alloc] init];
        _collectImageV.image = [UIImage imageNamed:@"ForumUnlike"];
        [self addSubview:_collectImageV];
         _collectImageV.tag = 1;
        _collectImageV.userInteractionEnabled = YES;
        [_collectImageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(_collectNumberLab.mas_left).offset(-5*screenW_6);
             make.top.equalTo(self).offset(14*screenW_6);
            make.size.mas_equalTo(CGSizeMake(13*screenW_6,12 * screenW_6));
        }];
        
        //评价数量
        _commentNumberLab = [UILabel new];
        _commentNumberLab.textColor = TextBlackGray;
        _commentNumberLab.font = [UIFont systemFontOfSize:15*screenW_6];
        _commentNumberLab.textAlignment = NSTextAlignmentLeft;
        _commentNumberLab.text = commentNumber;
        [_commentNumberLab sizeToFit];
        _commentNumberLab.tag = 0;
        [self  addSubview:_commentNumberLab];
        _commentNumberLab.userInteractionEnabled = YES;
        [_commentNumberLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(0);
            make.height.equalTo(@(40*screenW_6));
            make.width.equalTo(@(_commentNumberLab.frame.size.width+5*screenW_6));
            make.right.equalTo(_collectImageV.mas_left).offset(-10*screenW_6);
        }];
        
        //评价图片
        _commentImageV = [[UIImageView alloc] init];
        _commentImageV.image = [UIImage imageNamed:@"Foromcomment"];
        [self addSubview:_commentImageV];
        _commentImageV.tag = 0;
        _commentImageV.userInteractionEnabled = YES;
        [_commentImageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(_commentNumberLab.mas_left).offset(-5*screenW_6);
            make.top.equalTo(@(13.5*screenW_6));
            make.size.mas_equalTo(CGSizeMake(14*screenW_6,13*screenW_6 * screenW_6));
            make.bottom.equalTo(self).offset(-13.5*screenW_6);
        }];
        
        
        
        _creatTimeLab = [UILabel new];
        _creatTimeLab.textColor = TextBlackGray;
        _creatTimeLab.font = [UIFont systemFontOfSize:15*screenW_6];
        _creatTimeLab.textAlignment = NSTextAlignmentLeft;
        _creatTimeLab.text = @"520";
        [_creatTimeLab sizeToFit];
        _creatTimeLab.tag = 0;
        [self  addSubview:_creatTimeLab];
        _creatTimeLab.userInteractionEnabled = YES;
        [_creatTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(0);
            make.height.equalTo(@(40*screenW_6));
            make.left.equalTo(self).offset(15*screenW_6);
            make.right.equalTo(_commentImageV.mas_left).offset(-10*screenW_6);
        }];
        _creatTimeLab.hidden = YES;
        
        //添加点击事件
        UITapGestureRecognizer *commentTap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imagetap:)];
        UITapGestureRecognizer *commentTap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imagetap:)];
        UITapGestureRecognizer *commentTap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imagetap:)];
        UITapGestureRecognizer *commentTap4 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imagetap:)];
        [_collectImageV addGestureRecognizer:commentTap1];
        [_collectNumberLab addGestureRecognizer:commentTap2];
        [_commentImageV addGestureRecognizer:commentTap3];
        [_commentNumberLab addGestureRecognizer:commentTap4];
    }

    if (isCollect) {//自己已经收藏
        _collectImageV.image = [UIImage imageNamed:@"Forumliked"];
        _collectNumberLab.textColor = [UIColor colorWithHexString:@"ff6900"];
    }else
    {
        _collectImageV.image = [UIImage imageNamed:@"ForumUnlike"];
        _collectNumberLab.textColor = TextBlackGray;
    }

}

//点击评论的回调
-(void)imagetap:(UITapGestureRecognizer *)Tap
{
    if (_commentBlock) {
        self.commentBlock(Tap.view.tag);
    }
}

@end
